package models;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.BelongsTo;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.annotations.Unique;

import java.sql.*;

import utils.DateUtil;

//gd房源信息
@Table(name="estate2gd")
public class Estate2gd extends ActiveRecordBase{
	@Id private Integer id;
	@Column private String local_id;
	@Column private String web_id;
	@Column private String selfcode;
	@Column private Timestamp inputdate;
	@Column private Timestamp editdate;
	@Column private String mode;
	@Column private String city;
	@Column private String region;
	@Column private String name;
	@Column private String pyaddress;
	@Column private String fullpyaddress;
	@Column private String address;
	@Column private String detail_add;
	@Column private String circs;
	@Column private String purpose;
	@Column private String layer;
	@Column private String direction;
	@Column private String room;
	@Column private Float area;
	@Column private Float price;
	@Column private Float fzrf;
	@Column private String unit;
	@Column private Float totalprice;
	@Column private Timestamp datenumber;
	@Column private String scheduled_flag;
	@Column private String memo;
	@Column private String z_id;
	@Column private String unitname;
	@Column private String oper;
	@Column private String display;
	@Column private Integer totop;
	@Column private Integer toweb;
	@Column private String flag;
	@Column private String map;
	@Column private String fitment;
	@Column private String wg;
	@Column private String qt;
	@Column private Float sj;
	@Column private String usr_op_type;
	@Column private String dt_pos;
	@Column private String extra_memo;
    @Column private String phone_flag;
    @Column private Integer image_count;
    @Column private Integer video_count;
    
    public void setImage_count(Integer image_count){
		this.image_count=image_count;
	}
	public Integer getImage_count(){
		return image_count;
	}
    
	public void setVideo_count(Integer video_count){
		this.video_count=video_count;
	}
	public Integer getVideo_count(){
		return video_count;
	}
	
    public Integer getTimeout(){
		
		Date fDate = new Date(System.currentTimeMillis()); 
		Date oDate = new Date(editdate.getTime());
		
		return DateUtil.getIntervalDays(oDate ,fDate);
	}
    
    public void setFzrf(Float fzrf){
		this.fzrf = fzrf;
	}
	
	public Float getFzrf(){
		return fzrf;
	}
	
    public String getTotalunit(){
		  
		  if ((unit.equals("元/月/m2")) || (unit.equals("元/m2")) ||
		    (unit.equals("亩"))) 
		  {
		    if (unit.equals("元/月/m2")) 
		      return "元/月";
		    if ((unit.equals("元/m2")) || (unit.equals("亩")))
		      return "元";
		  }else{
		    if (unit.equals("万元/套")) {
		      return "元/套";
		    }
		    else
		    {
		      return unit;
		    }
		  }
		return unit;
	}
    
	public void setPhone_flag(String phone_flag){
		this.phone_flag=phone_flag;
	}
	public String getPhone_flag(){
		return phone_flag;
	}

    public String getDisplayhint(){
		
		switch (Integer.parseInt(display)){
		case 1:
			return "只在中介";
		case 2:
			return "只在本司";
		case 3:
			return "只在网站";
		case 0:
			return "无限制";		
		default:
			return "";
		}
	}
	//	@BelongsTo(foreignKey="demoId")
	//	private Demo demo;

	//	public Demo getDemo() {
	//		return demo;
	//	}
	//	public void setDemo(Demo demo) {
	//		this.demo = demo;
	//	}

	//	public int getChildCount() throws Exception {
	//		return (int)count(Estate2gd.class, "parentId=?", new Object[]{id});
	//	}
	//	public String findChildIds() throws Exception {
	//		String s = "";
	//		List<Integer> ids = new ArrayList<Integer>();
	//		ids.add(id);
	//		while(!ids.isEmpty()){
	//			int id = ids.remove(0);
	//			s += id + ",";
	//			for(Estate2gd item: Estate2gd.findAll(Estate2gd.class, "parentId=?", new Object[]{id})){
	//				ids.add(item.getId());
	//			}
	//		}
	//		if (!s.equals("")){
	//			s = s.substring(0, s.length() - 1);
	//		}
	//		return s;
	//	}
	public void setId(Integer id){
		this.id=id;
	}
	public Integer getId(){
		return id;
	}

	public void setLocal_id(String local_id){
		this.local_id=local_id;
	}
	public String getLocal_id(){
		return local_id;
	}

	public void setWeb_id(String web_id){
		this.web_id=web_id;
	}
	public String getWeb_id(){
		return web_id;
	}

	public void setSelfcode(String selfcode){
		this.selfcode=selfcode;
	}
	public String getSelfcode(){
		return selfcode;
	}

	public void setInputdate(Timestamp inputdate){
		this.inputdate=inputdate;
	}
	public Timestamp getInputdate(){
		return inputdate;
	}

	public void setEditdate(Timestamp editdate){
		this.editdate=editdate;
	}
	public Timestamp getEditdate(){
		return editdate;
	}

	public void setMode(String mode){
		this.mode=mode;
	}
	public String getMode(){
		return mode;
	}

	public void setCity(String city){
		this.city=city;
	}
	public String getCity(){
		return city;
	}

	public void setRegion(String region){
		this.region=region;
	}
	public String getRegion(){
		return region;
	}

	public void setName(String name){
		this.name=name;
	}
	public String getName(){
		return name;
	}

	public void setPyaddress(String pyaddress){
		this.pyaddress=pyaddress;
	}
	public String getPyaddress(){
		return pyaddress;
	}

	public void setFullpyaddress(String fullpyaddress){
		this.fullpyaddress=fullpyaddress;
	}
	public String getFullpyaddress(){
		return fullpyaddress;
	}

	public void setAddress(String address){
		this.address=address;
	}
	public String getAddress(){
		return address;
	}

	public void setDetail_add(String detail_add){
		this.detail_add=detail_add;
	}
	public String getDetail_add(){
		return detail_add;
	}

	public void setCircs(String circs){
		this.circs=circs;
	}
	public String getCircs(){
		return circs;
	}

	public void setPurpose(String purpose){
		this.purpose=purpose;
	}
	public String getPurpose(){
		return purpose;
	}

	public void setLayer(String layer){
		this.layer=layer;
	}
	public String getLayer(){
		return layer;
	}

	public void setDirection(String direction){
		this.direction=direction;
	}
	public String getDirection(){
		return direction;
	}

	public void setRoom(String room){
		this.room=room;
	}
	public String getRoom(){
		return room;
	}

	public void setArea(Float area){
		this.area=area;
	}
	public Float getArea(){
		return area;
	}

	public void setPrice(Float price){
		this.price=price;
	}
	public Float getPrice(){
		return price;
	}

	public void setUnit(String unit){
		this.unit=unit;
	}
	public String getUnit(){
		return unit;
	}

	public void setTotalprice(Float totalprice){
		this.totalprice=totalprice;
	}
	public Float getTotalprice(){
		return totalprice;
	}

	public void setDatenumber(Timestamp datenumber){
		this.datenumber=datenumber;
	}
	public Timestamp getDatenumber(){
		return datenumber;
	}

	public void setScheduled_flag(String scheduled_flag){
		this.scheduled_flag=scheduled_flag;
	}
	public String getScheduled_flag(){
		return scheduled_flag;
	}

	public void setMemo(String memo){
		this.memo=memo;
	}
	public String getMemo(){
		return memo;
	}

	public void setZ_id(String z_id){
		this.z_id=z_id;
	}
	public String getZ_id(){
		return z_id;
	}

	public void setUnitname(String unitname){
		this.unitname=unitname;
	}
	public String getUnitname(){
		return unitname;
	}

	public void setOper(String oper){
		this.oper=oper;
	}
	public String getOper(){
		return oper;
	}

	public void setDisplay(String display){
		this.display=display;
	}
	public String getDisplay(){
		return display;
	}

	public void setTotop(Integer totop){
		this.totop=totop;
	}
	public Integer getTotop(){
		return totop;
	}

	public void setToweb(Integer toweb){
		this.toweb=toweb;
	}
	public Integer getToweb(){
		return toweb;
	}

	public void setFlag(String flag){
		this.flag=flag;
	}
	public String getFlag(){
		return flag;
	}

	public void setMap(String map){
		this.map=map;
	}
	public String getMap(){
		return map;
	}

	public void setFitment(String fitment){
		this.fitment=fitment;
	}
	public String getFitment(){
		return fitment;
	}

	public void setWg(String wg){
		this.wg=wg;
	}
	public String getWg(){
		return wg;
	}

	public void setQt(String qt){
		this.qt=qt;
	}
	public String getQt(){
		return qt;
	}

	public void setSj(Float sj){
		this.sj=sj;
	}
	public Float getSj(){
		return sj;
	}

	public void setUsr_op_type(String usr_op_type){
		this.usr_op_type=usr_op_type;
	}
	public String getUsr_op_type(){
		return usr_op_type;
	}

	public void setDt_pos(String dt_pos){
		this.dt_pos=dt_pos;
	}
	public String getDt_pos(){
		return dt_pos;
	}

	public void setExtra_memo(String extra_memo){
		this.extra_memo=extra_memo;
	}
	public String getExtra_memo(){
		return extra_memo;
	}

}

